package string;

/**
 * @since Jan 22, 2018
 */
public class Intern {

    public static void main(String[] args) {
        String str1 = new StringBuilder("计算机").append("软件").toString();
        //[out]: true
        System.out.println(str1.intern() == str1);

        String str2 = new StringBuilder("ja").append("va").toString();
        //[out]: false
        //[reason]: there is "java" in the string constant pool before StringBuilder.toString().
        System.out.println(str2.intern() == str2);
    }
}
